package day14.pack3;

import day14.People;
import day14.Student;
import day14.Teacher;

import java.util.*;

public class TestTreeSet {
    public static void main(String[] args) {
        Comparator<People> comparator = (s1,s2) -> s1.getId() - s2.getId();
        List<Student> list = Arrays.asList(
                new Student(5, "A"),
                new Student(1, "B"),
                new Student(3, "C"),
                new Student(2, "D")
        );
        Collections.sort(list, comparator);
        list.forEach(System.out::println);

        // 有序,无序,排序
        // 按策略排序, 不可重复 Comparable
//
//
//        TreeSet<Student> students = new TreeSet<>();
//        students.add(new Student(10, "A"));
//        students.add(new Student(5, "B"));
//        students.add(new Student(3, "C"));
//        students.add(new Student(6, "D"));
//        students.forEach(System.out::println);
//
//        TreeSet<Teacher> teachers = new TreeSet<>();
//        teachers.add(new Teacher(10, "A"));
//        teachers.add(new Teacher(5, "B"));
//        teachers.add(new Teacher(3, "C"));
//        teachers.add(new Teacher(6, "D"));
//        teachers.forEach(System.out::println);
    }
}
